#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include<fcntl.h>
#include <pwd.h>
#include<time.h>
#include<utime.h>
#include <sys/types.h>
#include <sys/stat.h>
#define N_BITS 3
int main()
{
    unsigned int i, mask = 0700;
    struct stat buff;
    static char *perm[] = {"---", "--x", "-w-", "-wx", "r--", "r-x", "rw-", "rwx"};
    char *file = "/home/bzsg/workspace/study/linuxc/assets/des.txt";
    if (stat(file, &buff) != -1)
    { // 读取文件信息
        for (int i = 3; i > 0; i--)
        {  
            printf("%3s", perm[(buff.st_mode & mask) >> (i - 1) * N_BITS]);
            mask >>= N_BITS;
        }
        printf("\n");
    }
    return 0;
}